package com.yangrong.thread.chapter6;

import java.util.concurrent.TimeUnit;

public class ThreadInterrupt {

	public static void main(String[] args) {
		Thread thread = new Thread() {
			@Override
			public void run() {
				try {
					// 被调线程阻塞自己30s
					sleep(30000);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}
		};
		try {
			// 启动线程
			thread.start();
			// 主线程阻塞自己3秒
			TimeUnit.SECONDS.sleep(3);
			// 中断线程
			thread.interrupt();
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}
}
